import 'package:flutter/material.dart';
import 'package:meal/components/market/data_analysis.dart';
import 'package:meal/components/market/use_record.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/utils/tools.dart';

///
/// 满返代金券使用详情
///
class VoucherInfo extends StatefulWidget {
  const VoucherInfo({Key? key}) : super(key: key);

  @override
  State<VoucherInfo> createState() => _VoucherInfoState();
}

class _VoucherInfoState extends State<VoucherInfo> with SingleTickerProviderStateMixin {
  late TabController _controller;

  List<String> tabs = ['使用记录', '数据分析'];

  PreferredSizeWidget get bottom {
    return PreferredSize(
        preferredSize: const Size.fromHeight(Sizes.default50),
        child: Container(
          decoration: const BoxDecoration(
            color: Colors.white,
          ),
          alignment: Alignment.center,
          child: ToolsUtils.getClientTabBar(tabs, _controller),
        ));
  }

  @override
  void initState() {
    _controller = TabController(length: tabs.length, vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.getDefaultBrnAppBar('满返代金券使用详情', bottom: bottom),
      body: TabBarView(
        controller: _controller,
        children: const [MarketUseRecord(), MarketDataAnalysis()],
      ),
    );
  }
}
